<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新增角色</title>
<link href="/djzx/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/djzx/js/jquery-1.8.1.min.js"></script>
<script language="javascript" type="text/javascript" src="/djzx/js/My97DatePicker/WdatePicker.js"></script>
<script language="JavaScript" type="text/javascript" src="/djzx/js/backPage/clientSideApp.js"></script>
<script language="javascript">

function goback(){
	window.location.href="/djzx/RoleAction!getRoleListForPage.action";
}

function saveRole(){
	var name = $.trim($('#name').val());
	
	if(name==""){
		alert("角色名称不能为空");
		return;
	}
	
	var adminPower = 0;
	var oneLevelPower = 0;
	var twoLevelPower = 0;
	var oneLevelNO = "";
	var twoLevelNO = "";
	
	if ($('#adminPower').is(':checked')) { // 所有权限
		adminPower = 1;
	}else if ($('#communityPower').is(':checked')) { // 居民区
		oneLevelPower = 1;
		oneLevelNO = "00";
	}else if ($('#fgnPower').is(':checked')) { // 单个居民区党总支
		twoLevelPower = 1;
		oneLevelNO = "00";
		twoLevelNO = "1";
	}else if ($('#hkPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "00";
		twoLevelNO = "2";
	}else if ($('#zyjPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "00";
		twoLevelNO = "3";
	}else if ($('#xqPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "00";
		twoLevelNO = "4";
	}else if ($('#hbhyPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "00";
		twoLevelNO = "5";
	}else if ($('#ayPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "00";
		twoLevelNO = "6";
	}else if ($('#hxPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "00";
		twoLevelNO = "7";
	}else if ($('#psPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "00";
		twoLevelNO = "8";
	}else if ($('#hfPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "00";
		twoLevelNO = "9";
	}else if ($('#dlgPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "00";
		twoLevelNO = "10";
	}else if ($('#tlxcPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "00";
		twoLevelNO = "11";
	}else if ($('#hthyPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "00";
		twoLevelNO = "12";
	}else if ($('#lxPower').is(':checked')) { // 两新
		oneLevelPower = 1;
		oneLevelNO = "01";
	}else if ($('#sfPower').is(':checked')) { // 单个两新党总支
		twoLevelPower = 1;
		oneLevelNO = "01";
		twoLevelNO = "1";
	}else if ($('#jldtPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "01";
		twoLevelNO = "2";
	}else if ($('#hdPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "01";
		twoLevelNO = "3";
	}else if ($('#bkzjPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "01";
		twoLevelNO = "4";
	}else if ($('#bycPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "01";
		twoLevelNO = "5";
	}else if ($('#hlPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "01";
		twoLevelNO = "6";
	}else if ($('#qtPower').is(':checked')) {
		twoLevelPower = 1;
		oneLevelNO = "01";
		twoLevelNO = "7";
	}else if ($('#otherPower').is(':checked')) { // 其他辖区单位
		oneLevelPower = 1;
		oneLevelNO = "02";
	}else{
		alert('请选择角色');
		return;
	}
	
	var fd = new FormData();
	fd.append('role.name',name);
	fd.append('role.adminPower',adminPower);
	fd.append('role.oneLevelPower',oneLevelPower);
	fd.append('role.twoLevelPower',twoLevelPower);
	fd.append('role.oneLevelNO',oneLevelNO);
	fd.append('role.twoLevelNO',twoLevelNO);
	
	$.ajax({
	    url:"${pageContext.request.contextPath}/RoleAction!saveRole.action",
	    type:"POST",
	    data:fd,
	    dataType: "json", 
	    contentType: false, //必须
	    processData: false, //必须
	    success:function(data){
	    	alert(data.message);
			if(data.success){
				location.href="/djzx/RoleAction!getRoleListForPage.action";
			}
	    }
	}); 
}

</script>
<style type="text/css">
.firstTitle{

}
.secondTitle{
padding-left: 10px;
}
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td width="15"><img src="/djzx/images/index_32.gif" width="9" height="9"></td>
        <td valign="bottom" class="title">新增角色</td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<table align="center" width="95%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
        <td width="120" height="24" class="td_form01">角色名称</td>
        <td nowrap class=td_form02 colspan="3">
        	<input type="text" name="name" id="name" size="30" />
        </td>
      </tr>
      <tr>
        <td width="120" class="td_form01">角色</td>
        <td nowrap class=td_form02 colspan="3">
        	<input type="radio" name="role" id="adminPower" value="adminPower" />所有权限
        	<br />
        	<input type="radio" name="role" id="communityPower" value="communityPower" />居民区党组织
        	<br />
        	<div class="secondTitle">
	        	<input type="radio" name="role" id="fgnPower" value="fgnPower" />蕃瓜弄
	        	<br />
	        	<input type="radio" name="role" id="hkPower" value="hkPower" />华康
	        	<br />
	        	<input type="radio" name="role" id="zyjPower" value="zyjPower" />卓悦居
	        	<br />
	        	<input type="radio" name="role" id="xqPower" value="xqPower" />新桥
	        	<br />
	        	<input type="radio" name="role" id="hbhyPower" />河滨花园
	        	<br />
	        	<input type="radio" name="role" id="ayPower" />安源
	        	<br />
	        	<input type="radio" name="role" id="hxPower" />华新
	        	<br />
	        	<input type="radio" name="role" id='psPower' />普善
	        	<br />
	        	<input type="radio" name="role" id="hfPower" />华丰
	        	<br />
	        	<input type="radio" name="role" id="dlgPower" />地梨港
	        	<br />
	        	<input type="radio" name="role" id="tlxcPower" />铁路新村
	        	<br />
	        	<input type="radio" name="role" id="hthyPower" />和泰花园
        	</div>
        	<input type="radio" name="role" id="lxPower" />两新党组织
        	<br />
        	<div class="secondTitle">
	        	<input type="radio" name="role" id="sfPower" />上房方征投资管理（上海）有限公司总支委员会(6支部）
	        	<br />
	        	<input type="radio" name="role" id="jldtPower" />嘉里大通物流有限公司上海分公司党总支(3支部支部委员会)
	        	<br />
	        	<input type="radio" name="role" id="hdPower" />上海华东大酒店有限公司总支委员会（2支部）
	        	<br />
	        	<input type="radio" name="role" id="bkzjPower" />宝矿洲际商务中心综合党委（7支部）
	        	<br />
	        	<input type="radio" name="role" id="bycPower" />上海不夜城股份有限公司党委会(2支部)
	        	<br />
	        	<input type="radio" name="role" id="hlPower" />上海恒联企业发展有限公司党委会(3支部委员会）
	        	<br />
	        	<input type="radio" name="role" id="qtPower" />其他
        	</div>
        	<input type="radio" name="role" id="otherPower" />其他辖区单位
		</td>
      </tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><input name="Submit2" type="submit" class="buttonface" value="  保存  " onClick="saveRole()">
    <input name="Submit" type="submit" class="buttonface" value="  返回  "  onClick="goback()"></td>
  </tr>
</table>
<br>
</body>
</html>